<template>
  <div style="height:50px;line-height:50px;border-bottom: 1px solid #ccc;display: flex;width: 100%">
    <div style="width:200px;padding-left: 30px;font-weight: bold;color: dodgerblue">后台管理</div>
    <div style="flex: 1"></div>
    <div style="width: 100px;margin-top: 1%">
      <el-dropdown>
        <img :src="user.avatarUrl" alt=""
             style="width: 30px; border-radius: 50%; position: relative; top: 10px; right: 5px">
        <span class="el-dropdown-link">
          {{user.name}}
          <el-icon class="el-icon--right">
            <!-- 3.使用 -->
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="MyInformation">个人信息</el-dropdown-item>
            <el-dropdown-item @click="Exit">退出系统</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
//1.导入
import { ArrowDown } from "@element-plus/icons-vue";
import request from "@/utils/request";

export default {
  name: "Header.vue",
  created() {

  },
  props: {
    user: Object
  },
  data() {
    return {

    }
  },
  methods: {
    updateUser() {
      //更新一下最新数据
      let userJson = sessionStorage.getItem("user") || "{}"
      if(userJson){
        let user = JSON.parse(userJson)
        request.get("order/admin/getUserById",{params:{id:user.id}}).then((res) =>{
          this.user=res.data
        })
      }else{
        this.$message.error("当前无法修改用户信息!");
        return
      }
    },
    Exit() {
      this.$router.push("/login");
    },
    MyInformation(){
      this.$router.push("/person");
    }
  },
  components :{
    // 2.注册
    ArrowDown,
  }
}
</script>

<style scoped>

</style>